package com.envision.user.handler;

import com.envision.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <strong>Title : UserHandler.java<br>
 * </strong> <strong>Description : 用户handler</strong><br>
 * <strong>Create on : 2018年03月07日<br>
 * <p>
 *
 * @author karrychang<br>
 * @version <strong>1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人		修改日期		修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
@RestController
public class UserHandler {
    @Autowired
    private IUserService userServiceImpl;


    /** 
    *************************************************************************
     * UserHandler.java——login<br>
     * Author: karrychang<br>
     * Date: 2018/7/16<br>
     * Description:<br>
     * Used in：<br>
     * @param request
     * @param response
     * @return
     *************************************************************************
     */
    @RequestMapping(value = "/login")
    public String login(HttpServletRequest request, HttpServletResponse response){
        String name=request.getParameter("name");
        String password=request.getParameter("password");
        String msg=userServiceImpl.login(name,password, response, request);
        return msg;
    }
    /** 
    *************************************************************************
     * UserHandler.java——loginout<br>
     * Author: karrychang<br>
     * Date: 2018/7/16<br>
     * Description:<br>
     * Used in：<br>
     * @param request
     * @param response
     * @return
     *************************************************************************
     */
    @RequestMapping("/loginout")
    public String loginout(HttpServletRequest request ){
        userServiceImpl.loginout(request);
        return "{\"code\":200,\"msg\":\"login out sucess\"}";
    }
}
